package com.czxy.controller;

import com.czxy.pojo.Brand;
import com.czxy.service.BrandService;
import com.czxy.vo.BaseResult;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author 张青卯
 */
@RestController
@RequestMapping
public class BrandController {

    private final BrandService brandService;

    @Autowired
    public BrandController(BrandService brandService) {
        this.brandService = brandService;
    }

    @GetMapping("/brands")
    public ResponseEntity<Object> brands(@Param("catid") Integer catid){
        List<Brand> list = brandService.findBrandById(catid);
        BaseResult result = new BaseResult(0, "成功", list);
        return ResponseEntity.ok(result);
    }
}
